package top.jiangqiang.crawler.core.entities;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import top.jiangqiang.crawler.core.utils.JsonUtil;

import java.nio.charset.Charset;

@Getter
@Setter
@NoArgsConstructor
public class JsonCrawler extends TextCrawler {
    public <T> T jsonToObject(Class<T> tClass) {
        return JsonUtil.parse(getContent(), tClass);
    }

    public <T> T jsonToObject(Class<T> tClass, Charset charset) {
        return JsonUtil.parse(getContent(charset), tClass);
    }

}
